<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>

<html>
<head>
    <title>登录页</title>
    <%--echart线图、柱状图、饼图等各种图型库 cdn--%>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
    <%--jquery cdn--%>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
</head>
<body>
欢迎${name}登录   昵称${nickName} <img src="${avatarUrl}" style="height: 100px;width: 100px"> <a href="https://gitee.com/oauth/authorize?client_id=2d30b2b90394ed85121bcb1b16995a07ff3e02cb1d024782d7ba55470b3d1bb8&redirect_uri=http://localhost:8080/callbackCode.do&response_type=code">gitee登录</a>
<h1>-------------------</h1>

<form action="/list.do">
    学生<input name="studentName" value="${query.studentName}"><br>
    宿舍<input name="roomName" value="${query.roomName}"><br>
    楼号<input name="apartmentName" value="${query.apartmentName}"><br>
    <input type="submit" value="查询">
    <input type="button" onclick="excel()" value="导出">
    <a href="/addPage.do">入住</a>

    <table>
        <tr>
            <td>id</td>
            <td>宿舍</td>
            <td>图片</td>
            <td>楼号</td>
            <td>学生</td>
            <td>入住时间</td>
        </tr>
        <c:forEach items="${pageInfo.list}" var="s">
            <tr>
                <td>${s.id}</td>
                <td>${s.roomName}</td>
                <td><img src="${s.pic}" style="width: 50px;height: 50px"></td>
                <td>${s.apartmentName}</td>
                <td>${s.studentName}</td>
                <td>${s.createTime}</td>
            </tr>
        </c:forEach>

        <tr>
            <td>
                <button name="pageNum" value="1">首页</button>
                <button name="pageNum" value="${pageInfo.prePage}">上页</button>
                <button name="pageNum" value="${pageInfo.nextPage}">下页</button>
                <button name="pageNum" value="${pageInfo.pages}">尾页</button>
            </td>
        </tr>
    </table>
</form>
</body>
<script>

    function excel() {
        let studentName = $('[name=studentName]').val();
        let roomName = $('[name=roomName]').val();
        let apartmentName = $('[name=apartmentName]').val();

        location.href='/excel.do?studentName=' + studentName + '&roomName=' + roomName + '&apartmentName=' + apartmentName
    }
</script>
</html>